<template>
  <div id="box">
    <el-container>
      <el-header>
        <div class="logo">
          <div class="logo-left">用户名：{{ cardNo }}</div>
        </div>
        <!-- <div class="title"><span>欢迎使用马氏银行</span></div> -->
        <div class="operation">
          <el-dropdown trigger="click" @command="handleCommand">
            <span class="el-dropdown-link">
              <img src="../../assets/icon.webp" />
            </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item icon="el-icon-user" command="user"
                >个人中心</el-dropdown-item
              >
              <el-dropdown-item icon="el-icon-paperclip" command="link"
                >学术论坛</el-dropdown-item
              >
              <el-dropdown-item icon="el-icon-delete" command="logout"
                >退出登录</el-dropdown-item
              >
            </el-dropdown-menu>
          </el-dropdown>
        </div>
      </el-header>
      <el-container>
        <el-aside width="isCollapse?'100px':'200px'">
          <el-row class="tac">
            <el-col :span="12">
              <el-menu
                default-active="2"
                class="el-menu-vertical-demo"
                @open="handleOpen"
                @close="handleClose"
                background-color="#272c33"
                text-color="#fff"
                active-text-color="#ffd04b"
              >
                <el-submenu index="1">
                  <template slot="title">
                    <i class="el-icon-sort"></i>
                    <span @click="toWerk">人脸识别注册</span>
                  </template>
                </el-submenu>
              </el-menu>
            </el-col>
          </el-row>
        </el-aside>

        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
export default {
  data() {
    return {
      cardNo: localStorage.getItem("username"),

      isCollapse: false,
    };
  },

  methods: {
    toWerk() {
      this.$router.push("/werk_zc");
    },
    //...mapMutations([USERLOGIN, USERLOGOUT]),
    //获取侧边头像下拉框事件
    handleCommand(command) {
      //退出登录,并且需要清空vuex和sessionstorage中的内容
      if (command === "logout") {
        this.$router.push("/");
      }
      if (command === "link") {
        location.href = "https://blog.csdn.net/m0_63823719";
      }
    },
    destroyed: function () {
      // 离开当前页面
      this.stopNavigator(); // 关闭摄像头
    },
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
    doCollapse() {
      this.isCollapse = !this.isCollapse;
    },
  },
};
</script>

<style lang="less" scoped>
#box {
  width: 100%;
  height: 100%;
}
.logo-left {
  width: 500px;
  height: 100%;
  font-size: 20px;
  color: #fff;
  line-height: 60px;
  margin-left: 6px;
}
.el-container {
  height: 100%;
}

.el-header {
  display: flex;
  justify-content: space-between;
  background-color: #272c33;
  padding: 0 20px;

  img {
    width: 60px;
    height: 60px;
    border-radius: 50%;
  }
}

.login {
  margin-left: 20px;
}

.title {
  color: white;
  font-size: 26px;
  line-height: 60px;
}

.operation {
  margin-right: 20px;
}

.el-submenu {
  width: 200px;
}

.el-aside {
  width: 200px;
  height: 100%;
  background-color: #272c33;

  .collapse {
    background-color: #272c33;
    text-align: center;
    font-size: 26px;
    height: 30px;
    line-height: 30px;
    letter-spacing: 0.2em;
  }
}

.result_img {
  width: 226px;
  height: 195px;
  background: #d8d8d8;
}

.el-main {
  width: 100%;
  height: 100%;
  background-size: 100% 100%;
}
.el-dropdown-link {
  cursor: pointer;
  color: #409eff;
}

.el-icon-arrow-down {
  font-size: 12px;
}
.el-menu {
  border: 0;
}

.logo {
  color: #fff;
}
</style>
